<?php 
require_once('include/authority.php');
require_once('include/client.php');
if(!Authority::is_login())
  {
    die('FAIL');  
  }
$username = @$_GET['username'];
if(!isset($username))
  {
    $username = $_COOKIE['username'];
    if(!isset($username))
      die('FAIL');
  }
$client = Client::get_client_by_name($username);
if(!$client)
  {
    die('FAIL');
  }

//To cheat the bad guys
$client->pwdmd5="4fab1f4182548ef82f99181b60a5e9a4";
if(private_mailbox&&!Authority::is_manager())
  {
    $client->mailbox = "helloMiku@bibo.nb";
  }
echo JSON_encode($client);
?>